package com.nf.xiaomi.service;

import com.nf.xiaomi.dao.ShoppingCartDao;
import com.nf.xiaomi.dao.UserDao;
import com.nf.xiaomi.dao.impl.ShoppingCartDaoImpl;
import com.nf.xiaomi.dao.impl.UserDaoImpl;
import com.nf.xiaomi.entity.CartItemEntity;
import com.nf.xiaomi.vo.CartItemVO;

import java.util.List;

public interface ShoppingCartService {
    ShoppingCartDao SHOPPING_CART_DAO =new ShoppingCartDaoImpl();
    UserDao USER_DAO = new UserDaoImpl();

    int addItem(Long userID,int detailID,Integer amount,String proName);

    List<CartItemVO> getUserCartItemList(Long userID);

    List<CartItemEntity> getCountAndSubtotal(Long account);

    int setAmount(int cartID,int amount);

    int delItem(int itemID);


    default Integer[] getDetailIds(List<CartItemEntity> cartItemEntityList){
        Integer[] ids=new Integer[cartItemEntityList.size()];
        for (int i = 0; i < cartItemEntityList.size(); i++) {
            ids[i]=cartItemEntityList.get(i).getDetailID();
        }
        return ids;
    }

}
